import java.util.LinkedList;

public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param arr int整型一维数组 the array
     * @return int整型
     */
    public int maxLength (int[] arr) {
        // write code here
        LinkedList<Integer> list = new LinkedList<Integer>();
        //int beginIndex = 0;
        //int endIndex = 0;
        int longest = 0;
        //1.遍历数组，将链表中不存在且数组中连续的数据放入链表中
        for (int i = 0; i < arr.length; i++) {
            int begin = i;
            int end = i+1;
            for (int j = i; j < arr.length; j++) {
                if (list.contains(arr[j])) {
                    list.remove();
                    break;
                }else {
                    list.add(arr[j]);
                }
                end = j+1; 
            }
            if(longest < end-begin){
                longest = end-begin;
                //beginIndex = begin;
                //endIndex = end;
            }
        }
        return longest;
    }
}